//
// Created by bleedingfight on 2020/7/1.
//
#include "sqrt.h"
#include <iostream>
int mySqrt(int n) {
  if (n == 0)
    return 0;
  double x_current = 0;
  double x_next = n / 2;
  while (x_current != x_next) {
    x_current = x_next;
    x_next = (x_current + n / x_current) / 2;
  }
  return int(x_current);
}
